import java.math.BigDecimal;
import java.math.MathContext;

public class Truck extends Car {
	private Integer weight;

	public Truck(String color, BigDecimal price, Integer weight) {
		super(color, price);
		setWeight(weight);
	}

	public Integer getWeight() {
		return weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

	public BigDecimal getDiscountedPrice() {
		BigDecimal discountedPrice;
		BigDecimal discount;
		MathContext mc = new MathContext(5);

		if (getWeight() < 2000) {
			discountedPrice = getPrice();
		} else {
			discount = (new BigDecimal(0.1)).multiply(getPrice());
			discountedPrice = getPrice().subtract(discount).round(mc);
		}

		return discountedPrice;
	}
}
